<template>
  <div>
    <Headers />
    <DigitMap :is-search="isMaxMap" :base-list="baseList"  :land-list="landList" @complete="complete" class="container-map"></DigitMap>

    <Transition name="left">
      <div v-if="!isMaxMap" class="left">
        <LeftUp class="left_up" />
        <LeftCenter class="left_center" />
        <LeftDown class="left_down" />
      </div>
    </Transition>

    <div class="center">
      <CenterUp class="center_up" />
      <!-- <CenterDown class="center_down" /> -->

      <!-- <div @click="isMaxMap = !isMaxMap" class="max-btn">
        <FullscreenExitOutlined v-if="isMaxMap"  />
        <FullscreenOutlined v-else />
        {{ isMaxMap ? '地图恢复' : '地图全屏' }} 
      </div> -->
    </div>

    <!-- <Amap :showSearch="false" @complete="complete" @click="mapClick" class="container-map"></Amap> -->

    <Transition name="right">
      <div v-if="!isMaxMap" class="right">
        <RightUp class="right_up" />
        <!-- <RightCenter class="right_center" /> -->
        <RightDown ref="rightDownDiv" class="right_down" />
      </div>
    </Transition>
    <Transition name="fade">
      <img v-if="!isMaxMap" src="../../assets/bg2.png" class="bgimg" />
    </Transition>
  </div>
</template>
<script>
export default {
  name: 'industryResourcesIndex'
}
</script>
<script setup>
import { FullscreenOutlined, FullscreenExitOutlined } from '@ant-design/icons-vue';
import { message } from "ant-design-vue";
import Headers from "../../components/Header.vue";

import LeftUp from "./component/LeftUp.vue";
import LeftCenter from "./component/LeftCenter.vue";
import LeftDown from "./component/LeftDown.vue";
import CenterUp from "./component/CenterUp.vue";
import CenterDown from "./component/CenterDown.vue";
import RightUp from "./component/RightUp.vue";
import RightCenter from "./component/RightCenter.vue";
import RightDown from "./component/RightDown.vue";

import { ref, onMounted } from "vue";
import http from "@/api/http";
import { env } from "@/utils/env";

import { useRoute, useRouter } from "vue-router";
import { useBaseStore } from "@/stores/base";
import { useLandStore } from "@/stores/land";
import DigitMap from "@/components/Amap/digitMap.vue";
import { getBaseList } from "@/api/baseApi";
import { getLandList } from "@/api/landApi";
import markerBlue from '@/assets/map/marker-blue.png'

const rightDownDiv = ref()
const baseStore = useBaseStore()
const landStore = useLandStore()
const route = useRoute()
const router = useRouter()
let map = null
const baseList = ref([])
const landList = ref([])
const isMaxMap = ref(false)
const complete = async (e) => {
  map = e

  let markerList = []
  let res = await http({
    url: env.VITE_ZHER_DATA_CENTER + "/property/main/list",
    method: "get",
    params: {
      pageNum: 1,
      pageSize: 1000,
      keyEnt: 1,
      // yearly: new Date().getFullYear()
    },
  });

   let conta = {}
  let list = res.data.list.filter((item) => {
    if(conta[item.code]){
      return false
    } else {
      conta[item.code] = 1
      return true

    }
  })
  
  for(let item of list){
    let icon = new AMap.Icon({
      size: new AMap.Size(25, 34), // 图标尺寸
      image: markerBlue,
      imageSize: new AMap.Size(25, 34),
    });

    let marker = new AMap.Marker({
      icon: icon,
      position: [item.lng, item.lat],
      anchor: 'bottom-center',
      extData: {type: 1},
      map
    });
    markerList.push(marker)

    marker.on('click', () => {
      
      rightDownDiv.value.toDevice(item)
    })

    new AMap.Text({
      text: item.name ,
      anchor: 'center', // 设置文本标记锚点
      angle: 0,
      offset: new AMap.Pixel(0, -60),
      style: {
        'text-align': 'center', background: '#58aaf9ee', border: 'none', color: '#fff', 'font-size': '16px', 'box-shadow': '0 0 5px 0 rgba(0, 0, 0, 0.5)', padding: '5px 10px'

      },
      position: [item.lng, item.lat],
      zIndex: 100,
      extData: {type: 1},
      map
    });
  }
  
  map.setFitView(markerList, false, [100, 100, 200, 200])
}



onMounted(() => {

})
</script>
<style scoped lang="scss">
.bgimg {
  width: 100%;
  height: 100%;
  z-index: 5;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  opacity: 1;
}

.container-map {
  height: 100%;
  width: 48vw;
  padding: 0px;
  margin: 0px;
  box-shadow: 0 0 vw(80) vw(40) rgba(30, 73, 98, 1) inset;
  position: absolute;
  left: 50%;
    transform: translateX(-50%);
}

.content {
  display: flex;
  justify-content: space-between;
  position: relative;
}

.left {
  width: 27%;
  z-index: 10;
  position: relative;
  left: 0;
  float: left;
}

.left_up {
  margin: vh(10) vw(10);
  height: vh(230);
}

.left_center {
  margin: vh(10) vw(10);
  height: vh(230);
}

.left_down {
  margin: vh(10) vw(10);
  height: vh(240);
}

.center {
  width: 46%;
  position: absolute;
  top: 3.8vw;
  left: 27%;

}

.center_up {
  // height: vh(475);
  // z-index: 10;
  // pointer-events: none;
  margin: vh(10) vw(10);
}

.center_down {
  height: vh(230);
  margin: vh(10) vw(10);
  // z-index: 10;
  pointer-events: auto;

  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.right {
  width: 27%;
  z-index: 100;
  position: relative;
  float: right;
  left: 0;
}

.right_up {
  margin: vh(10) vw(10);
  height: vh(350);
}

.right_center {
  margin: vh(10) vw(10);
  height: vh(230);
}

.right_down {
  margin: vh(10) vw(10);
  height: vh(360);
}

.max-btn {
  background: #054f63;
  // color: #2cd7bc;
  color: #fff;
  font-size: 16px;
  padding: 10px 20px;
  cursor: pointer;
  position: absolute;
  z-index: 100;
  top: vh(8);
  right: 0;
}

.left-enter-active,
.left-leave-active {
  transition: 1s;

}

.left-enter-from,
.left-leave-to {
  left: -100%;
}

.right-enter-active,
.right-leave-active {
  transition: 1s;

}

.right-enter-from,
.right-leave-to {
  left: 100%;
}

.fade-enter-active,
.fade-leave-active {
  transition: 1s;

}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>